package routers

import (
	"CMETO/controllers/menuController"
	"CMETO/controllers/roleMenuController"
	middleware "CMETO/middlewares"

	"github.com/gin-gonic/gin"
)

func MenuApi(r *gin.RouterGroup) {
	var menu menuController.MenuController
	var menuRole roleMenuController.RoleMenuController
	menuRouter := r.Group("/menu", middleware.JWTAuthPlus())
	{
		menuRouter.GET("/", menu.QueryMenus)
		menuRouter.GET("/:id", menu.QueryMenuById)
		menuRouter.GET("/lower/:id", menu.QueryMenuLower)
		menuRouter.GET("/upper/:id", menu.QueryMenuUpper)
		menuRouter.POST("/", menu.AddMenu)
		menuRouter.PUT("/", menu.UpdateMenu)
		menuRouter.DELETE("/", menu.DeleteMenu)
	}
	menuRoleRouter := r.Group("/menurole", middleware.JWTAuthPlus())
	{
		menuRoleRouter.GET("/tree", menuRole.QueryRoleMenuTrees)
		menuRoleRouter.GET("/role", menuRole.QueryRoleMenus)
		menuRoleRouter.GET("/tree/nobtn", menuRole.QueryRoleMenuTreesNoBtn)
		menuRoleRouter.GET("/btn", menuRole.QueryRoleBtn)
		menuRoleRouter.POST("/", menuRole.AddMenuWithRole)
		menuRoleRouter.PUT("/", menuRole.UpdateMenuWithRole)
	}
}
